<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>计算属性</title>
    <script src="https://cdn.jsdelivr.net/npm/vue/dist/vue.js"></script>
</head>
<body>
<div id="app">
    <span>{{msg}}</span><br>
    <span>{{msg.split('').reverse().join('')}}</span><br><br>
    <span>{{reverseStr}}</span><br>
    <span>{{reverseStr}}</span><br>
    <span>{{reverseFun()}}</span><br>
    <span>{{reverseFun()}}</span><br>
</div>

<script type="text/javascript">

    var app=new Vue({
        el:'#app',
        data:{
            msg:'phpvue'
        },
        methods:{
            reverseFun:function(){
                //多次调用执行多次
                console.log('methods');
                return this.msg.split('').reverse().join('')
            }
        },

        computed:{
            reverseStr:function(){
                //多次使用只会执行一次
                console.log('computed');
                return this.msg.split('').reverse().join('')
            }
        }


    })
</script>


</body>
</html>